#include<bits/stdc++.h>
#define ll long long
using namespace std;
long long T;
bool flag=true,flag2=true;
long long n,m,L,V;
struct Node{
    long long d,v,a;
}cr[111111];
long long mch[111111];
long long getsp(Node x,long long p)
{
    if(x.d>p)return -1;
    long long y=x.v*x.v+2*x.a*(p-x.d),ans=x.v;
    while(ans*ans<y)
        ans++;
    return ans-1;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    for(long long p=0;p<T;p++){
    cin>>n>>m>>L>>V;
    for(long long i=0;i<n;i++){
        cin>>cr[i].d>>cr[i].v>>cr[i].a;
        if(cr[i].a!=0)flag=false;
        if(cr[i].a<0)flag2=false;
    }
    for(long long i=0;i<m;i++){
        cin>>mch[i];
    }
    //cout<<"IN";
    if(flag){
        //cout<<"IN";
        long long tms=0;
        for(long long i=0;i<n;i++){
            if(cr[i].v>V&&cr[i].d<=mch[m-1])tms++;
        }
        if(tms!=0)cout<<tms<<' '<<m-1<<endl;
        else cout<<0<<' '<<m<<endl;
        continue;
    }//A20
    if(flag2){
        long long tms=0;
        for(long long i=0;i<n;i++){
            if(getsp(cr[i],mch[m-1])>V)tms++;
        }
        if(tms!=0)cout<<tms<<' '<<m-1<<endl;
        else cout<<0<<' '<<m<<endl;
        continue;
    }

    }
    return 0;
}

